package com.music.controller;

import com.music.dto.Result;
import com.music.entity.District;
import com.music.service.DistrictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Classname DistrictController
 * @Description TODO
 * @Version 1.0.0
 * @Date 2022/7/5 13:40
 * @Created by Administrator
 */
@RestController
@RequestMapping("/district")
public class DistrictController {

    @Autowired
    private DistrictService districtService;

    @GetMapping
    public @ResponseBody
    Result getAllDistrict(){
        Result result = new Result();
        List<District> districtList = districtService.getAllDistrict();
        if(districtList.isEmpty()){
            result.fail(0,"没有相关数据");
        }else{
            result.ok(districtList);
        }
        return  result;
    }
}
